home *** CD-ROM | disk | FTP | other *** search
- // WIN32アプリケーションサンプル
- // WIN32Sample.cpp
-
- #include "stdafx.h"
- #define APPNAME "WIN32Sample"
-
- HINSTANCE hAppInst;
-
- LRESULT CALLBACK WndProc(HWND, UINT, UINT, LONG);
-
- int APIENTRY WinMain(HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpCmdLine,
- int nCmdShow)
- {
-
- WNDCLASS wc;
- HWND hWnd;
- MSG msg;
-
- wc.style=CS_HREDRAW|CS_VREDRAW;
- wc.lpfnWndProc=WndProc;
- wc.cbClsExtra=0;
- wc.cbWndExtra=0;
- wc.hInstance=hInstance;
- wc.hIcon=NULL;
- wc.hCursor=LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
- wc.lpszMenuName=0;
- wc.lpszClassName=APPNAME;
-
- RegisterClass(&wc);
-
- hAppInst=hInstance;
- // ウィンドウクラスの登録
- hWnd=CreateWindowEx(0,APPNAME,APPNAME,WS_OVERLAPPEDWINDOW,
- 0,0,640,480,NULL,NULL,hInstance,NULL);
-
- if(!hWnd) return FALSE;
-
- ShowWindow(hWnd, nCmdShow);
- UpdateWindow(hWnd);
-
- // メッセージポンプ
- while(GetMessage(&msg, NULL, 0, 0)){
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return msg.wParam;
- }
-
- long FAR PASCAL WndProc(HWND hWnd, UINT message,
- WPARAM wParam, LPARAM lParam)
- {
- switch(message){
-
- case WM_KEYDOWN:
- switch(wParam){
-
- case VK_ESCAPE:
- DestroyWindow(hWnd);
- break;
- }
- return TRUE;
-
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- }
- return DefWindowProc(hWnd, message, wParam, lParam);
- }
-